package com.wc.codeforces.思维.All_Pairs_Segments;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/10/4 9:14
 * @description https://mirror.codeforces.com/problemset/problem/2019/B
 */
public class Main {
    /**
     * 题目意思：
     * 给出 n 个点x[i] ~ x[n]
     * 每两个点之间形成一个线段一共有 C(n, 2) 条线段
     * q次询问, 问: 有多少个坐标点被 k 条线段覆盖
     * <p>
     * 思路：
     * <p>
     * 1、x[i] ~ x[n] 的坐标点
     * 他们起始或者是结束的线段有 n - 1 条
     * 横跨的有 前面有 i - 1 个点, 后面有 n - i 个点
     * 那么就有 (i - 1) * (n - i) 个线段经过
     * 思路明确 res = n - 1 + (i - 1) * (n - i)
     * <p>
     * 2、x[i] - x[n - 1]之间的点有 x[i] - x[i - 1] - 1 个点
     * 那只需要算横跨的点
     * 前面有 i - 1 个点, 后面有 n - i + 1 个点
     * 那么就有 (i - 1) * (n - i + 1) 个线段经过
     * 思路明确 res = (i - 1) * (n - i + 1)
     * <p>
     * 3、存储时候用map最好
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 100010;
    static int[] x = new int[N];
    static Map<Long, Long> map = new HashMap<>();
    static int n, m;

    public static void main(String[] args) {
        int T = sc.nextInt();
        while (T-- > 0) {
            n = sc.nextInt();
            m = sc.nextInt();
            for (int i = 1; i <= n; i++) x[i] = sc.nextInt();
            x[0] = x[1];
            for (int i = 1; i <= n; i++) {
                add((long) (i - 1) * (n - i + 1), x[i] - x[i - 1] - 1);
                add(n - 1 + (long) (i - 1) * (n - i), 1);
            }
            while (m-- > 0) {
                long k = sc.nextLong();
                out.print(map.getOrDefault(k, 0L) + " ");
            }
            out.println();
            map.clear();
        }
        out.flush();
    }

    static void add(long x, long c) {
        map.put(x, map.getOrDefault(x, 0L) + c);
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
